package com.rainng.coursesystem.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;

@TableName("rc_course_resource")
@Data
public class CourseResourceEntity {
    public static final String ID = "id";
    public static final String COURSE_ID = "course_id";
    public static final String PATH = "path";
    public static final String TYPE = "type";
    public static final String NAME = "name";

    @NotNull
    @TableId(value = ID, type = IdType.AUTO)
    private Integer id;

    @NotNull(message = "课程 ID 不能为空")
    @TableField(COURSE_ID)
    private Integer courseId;

    @NotBlank(message = "资源路径不能为空")
    @TableField(PATH)
    private String path;

    @NotNull(message = "资源类型不能为空")
    @Range(min = 0, max = 1, message = "资源类型值只能为 0（视频）或 1（文件）")
    @TableField(TYPE)
    private Integer type;

    @NotBlank(message = "资源名称不能为空")
    @TableField(NAME)
    private String name;
}    